package com.wlld.myjecs.controller;

import org.apache.ibatis.annotations.Param;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Controller
public class RouteController {


    @RequestMapping("/index")
    public String index() {
        return "index";
    }
    @Resource
    private Environment environment;
    @RequestMapping("/admin")
    public String admin(Model model, HttpServletResponse response, @RequestParam String tokenID) {
        response.setHeader("tokenID",tokenID);
        String path = environment.getProperty("server.servlet.context-path");
        path = StringUtils.isEmpty(path) ? "" : path;
        String talk=("http://localhost:"
                + environment.getProperty("server.port")
                + path+"/doc.html");
        model.addAttribute("talk",talk);
        return "admin";
    }
    @RequestMapping("/worker")
    public String worker(HttpServletResponse response, @RequestParam String tokenID) {
        response.setHeader("tokenID",tokenID);
        return "worker";
    }
}
